package com.quanyan.stadium.biz;

import com.quanyan.stadium.entity.*;
import com.quanyan.stadium.entity.vo.VDefinedGameSchedule;

import java.util.List;
import java.util.Map;

/**
 * Created by xiao.lai on 16/5/26.
 */
public interface BizGameSystemDao {


    /**
     * 插入 TbGameEvent
     *
     * */
    TbGameEvent insertTbGameEvent(TbGameEvent tbGameEvent);

    /**
     * 更新 TbGameEvent,根据id
     *
     * */
    TbGameEvent updateTbGameEvent(TbGameEvent tbGameEvent);

    /**
     * 获取俱乐部创建的赛事正在处于报名阶段的
     *
     * */
    int countGameEventSigningByClubId(Integer clubId);

    /**
     * 获取俱乐部创建的赛事正在处于进行阶段的
     *
     * */
    int countGameEventPlayingByClubId(Integer clubId);

    /**
     * 查询TbGameEvent,根据id
     *
     * */
    TbGameEvent selectTbGameEvent(Integer id);

    /**
     * 取消活动
     *
     * */
    TbGameEvent cancelGameEvent(Integer id);

    /**
     * 查询TbGameEvent,根据clubId
     *
     * */
    List<TbGameEvent> selectTbGameEventByClubId(Integer clubId, Integer pageNum, Integer pageSize);

    /**
     * 查询TbGameEvent,根据clubId
     *
     * */
    List<TbGameEvent> selectTbGameEventByClubIdNotGameType(Integer clubId, Byte gameType, Integer pageNum, Integer pageSize);

    /**
     * 查询TbGameEvent,根据clubId
     *
     * */
    List<TbGameEvent> selectTbGameEventByClubId(List<Integer> clubIds);

    /**
     * 根据场馆placeId, categoryId, cityId, districtId,
     *
     * */
    List<TbGameEvent> selectTbGameEventByPlaceIdAndCategoryId(Integer categoryId, Integer cityId, Integer districtId, Integer placeId);

    /**
     * 查询积分生成状态
     *
     * 当前的处于排位赛阶段,检索处于排位阶段得官方赛事
     *
     * */
    List<TbGameEvent> selectTbGameEventScoreStatus(boolean isComplemente);

    /**
     * 查询TbGameEvent,根据parentId
     *
     * */
    List<TbGameEvent> selectTbGameEventByParentId(Integer parentId);

    /**
     * 查询TbGameEvent,根据parentId
     *
     * */
    List<TbGameEvent> selectTbGameEventByParentIds(List<Integer> parentIds);

    /**
     * 查询某场馆下的积分赛
     *
     * */
    List<TbGameEvent> selectTbGameEventByPlaceId(Integer placeId, Integer pageNum, Integer pageSize);

    /**
     * 查询场馆对应的场馆赛
     *
     * */
    List<TbGameEvent> selectTbGameEventPlaces(List<Integer> placeIds, Integer districtId,  Integer categoryId);

    /**
     * 查询 未开始报名的的排位赛,根据栏目id 场馆id
     *
     * */
    List<TbGameEvent> selectNotSignStartTbGameEventByPlaceIdAndCategoryId(Integer categoryId, Integer placeId);

    /**
     * 查询TbGameEvent,根据clubId
     *
     * */
    int countTbGameEventByClubIdNotGameType(Integer clubId, Byte gameType);

    /**
     * 插入TbGameRound
     *
     * */
    TbGameRound insertTbGameRound(TbGameRound tbGameRound);

    /**
     * 更新 TbGameEvent,根据id
     *
     * */
    TbGameRound updateTbGameRound(TbGameRound tbGameRound);

    /**
     * 查询 TbGameEvent,根据id
     *
     * */
    List<TbGameRound> selectTbGameRoundByGameEventId(Integer gameEventId);

    /**
     * 查询 TbGameEventTeam,根据uid,和俱乐部id集合;uid和clubIds互斥条件出现
     *
     * */
    List<TbGameEventTeam> selectMyTbGameEventTeam(Integer uid, List<Integer> clubIds, Byte teamType);

    /**
     * 查询 TbGameEventTeam,根据uid,和俱乐部id集合;uid和clubIds互斥条件出现
     * @param idList
     * @param teamType
     * @param gameEventId
     * @return
     */
    List<TbGameEventTeam> selectTbGameEventTeam(List<Integer> idList, Byte teamType, Integer gameEventId);

    /**
     * 查询 TbGameEvent,根据gameEventId获取已经生成对战表的轮次
     *
     * */
    List<TbGameRound> selectTbGameRoundByGameEventIdAndGenerate(Integer gameEventId);

    /**
     * 查询 TbGameEvent,根据gameEventId获取已经生成对战表的轮次()
     *
     * */
    List<TbGameRound> selectTbGameRoundByGameEventIdAndGenerateNotCur(Integer gameEventId);


    TbGameRound selectTbGameRound(Integer id);

    /**
     * 插入TbGameEventTeam
     *
     * */
    TbGameEventTeam insertTbGameEventTeam(TbGameEventTeam tbGameEventTeam);

    /**
     * 更新 TbGameEventTeam,根据id
     *
     * */
    TbGameEventTeam updateTbGameEventTeam(TbGameEventTeam tbGameEventTeam);

    /**
     * 查询赛事下的报名队伍信息
     *
     * */
    List<TbGameEventTeam> selectTbGameEventTeamByGameEventId(Integer gameEventId, Integer pageNum, Integer pageSize, Byte isDelete);

    TbGameEventTeam selectTbGameEventTeamById(Integer id);

    /**
     * 按照ids的顺序输出,需要注意
     *
     * */
    List<TbGameEventTeam> selectTbGameEventTeamByIds(List<Integer> ids);

    int countTbGameEventTeamByGameEventId(Integer gameEventId);

    /**
     * 插入TbGameSchedule
     *
     * */
    TbGameSchedule insertTbGameSchedule(TbGameSchedule tbGameSchedule);

    /**
     * 更新 TbGameEventTeam,根据id
     *
     * */
    TbGameSchedule updateTbGameSchedule(TbGameSchedule tbGameSchedule);

    /**
     * 查询 TbGameSchedule,根据gameRoundId
     *
     * */
    List<TbGameSchedule> selectTbGameScheduleByGameRoundId(Integer gameRoundId, Integer pageNum, Integer pageSize);

    /**
     * 查询 TbGameSchedule,根据gameRoundId
     *
     * @param gameRoundId
     * @return
     */
    List<TbGameSchedule> selectTbGameScheduleByGameRoundId(Integer gameRoundId);

    /**
     * 自定义查询
     *
     * */
    List<VDefinedGameSchedule> selectVDefinedGameScheduleByGameRoundId(Integer gameRoundId, Integer pageNum, Integer pageSize);

    /**
     * 自定义查询
     *
     * */
    List<VDefinedGameSchedule> selectVDefinedGameScheduleById(Integer gameScheduleId);

    /**
     * TbGameRoundScore
     *
     * */
    TbGameRoundScore insertTbGameRoundScore(TbGameRoundScore tbGameRoundScore);

    /**
     * 更新 TbGameRoundScore,根据id
     *
     * */
    TbGameRoundScore updateTbGameRoundScore(TbGameRoundScore tbGameRoundScore);
    /**
     * 查询 TbGameRoundScore,gameRoundId,并且按score进行排序
     *
     * */
    List<TbGameRoundScore> selectTbGameRoundScoreByGameRoundId(Integer gameRoundId, Integer pageNum, Integer pageSize);

    /**
     * 查询 TbGameRoundScore,gameRoundIdList,并且按score进行排序
     * @param gameRoundIdList
     * @param pageNum
     * @param pageSize
     * @return
     */
    List<TbGameRoundScore> selectTbGameRoundScoreByGameRoundId(List<Integer> gameRoundIdList, Integer pageNum, Integer pageSize);

    /**
     * 查询 TbGameRoundScore,gameRoundId,并且按score进行排序
     *
     * */
    List<TbGameRoundScore> selectTbGameRoundScoreByGameRoundIds(List<Integer> gameRoundIds);

    /**
     * 查询 TbGameRoundScore,gameRoundId,teamId
     *
     * */
    TbGameRoundScore selectTbGameRoundScoreByGameRoundIdAndTeamId(Integer gameRoundId, Integer teamId);

    /**
     * 查询 TbGameScheduleAddendum
     *
     * */
    List<TbGameScheduleAddendum> selectTbGameScheduleAddendumByGameScheduleId(Integer gameScheduleId);

    boolean updateGameStorage(Integer id, int num);

    /**
     * @param tbGameOrder
     * @return
     */
    TbGameOrder insertGameOrder(TbGameOrder tbGameOrder);

    /**
     * 下单
     * @param tbGameOrder
     * @return
     */
    TbGameOrder updateTbGameOrder(TbGameOrder tbGameOrder);

    /**
     * 插入赛事积分记录
     * @param tbGameEventScore
     * @return
     */
    void insertTbGameEventScore(TbGameEventScore tbGameEventScore);

    /**
     * 查询赛事下的用户,根据isDelete状态来区分,按score排序
     * @param gameEventId
     * @return
     */
    List<TbGameEventTeam> selectTbGameEventTeamByGameEventId(Integer gameEventId, Byte isDelete);

    /**
     * 查新举行的所有轮次根据当前的轮次id
     *
     * @param roundid
     * @return
     */
    List<TbGameRound> selectProceedsGameRoundByGameRoundid(Integer roundid);

    /**
     *  查询当前俱乐部授权的场馆id
     * @param
     * @return
     */

    List<TbGameClubOfficial> queryTbGameOfficialClubList(Integer clubId,  Integer categoryId);
    /**
     *  赛事积分表信息查询, 排名输出
     * @param
     * @return
     */

    List<TbGameEventScore> queryTbGameEventScoreList(Integer gameEventId);
    /**
     * 根据赛事id返回双打匹配
     *
     * @param
     * @return
     */

    List<TbTeamDoubleAddendum> queryTbTeamDoubleAddendumList(Integer gameEventId);

    /**
     * 更新个人赛程表的赛事状态为结束
     *
     * */
    void updateUserGameScheduleFinish(Integer gameScheduleId, String score, Integer uid, boolean isAdmin,  Byte isWin);

    /**
     * 赛事搜索
     *
     * @param searchMap
     * @return
     */
    List<TbGameEvent>  gameEventSearch(Map<String, Integer> searchMap);
    /**
     * 更新赛事下俱乐部代表队
     *
     * @return
     */
    void  initTbGameClubTeamUser(Integer gameEventId, Integer clubId, List<Integer> uids, Integer gameTeamId);
    /**
     * 根据clubId 和 gameEventId后去代表队信息
     *
     * @return
     */
    List<TbGameClubTeamUser>  queryTbGameClubTeamUserByClubId(Integer gameEventId, Integer clubId);

    /**
     * 根据clubId 和 uid 获取信息
     *
     * @return
     */
    List<TbGameClubTeamUser>  queryTbGameClubTeamUserByUid(Integer gameEventId, Integer uid);

    /**
     * 根据赛程id和uid查询等级分记录
     *
     * @return
     */
    List<TbUserFLScore>  queryTbUserFLScoreByUid(List<Integer> gameScheduleIds, Integer uid);

    /**
     * 根据赛事id和uid查询等级分记录
     *
     * @return
     */
    List<TbUserGameSchedule>  queryTbUserGameScheduleByUid(Integer gameEventId, Integer uid);

    /**
     * 更新数据
     *
     * @return
     */
    int  updateTbUserGameScheduleByUid(TbUserGameSchedule tbUserGameSchedule);

    /**
     * 根据赛程id查询赛程
     * @param gameScheduleId
     * @return
     */
    TbGameSchedule selectTbGameScheduleById(Integer gameScheduleId);

    /**
     * 根据赛程id批量删除
     * @param gameScheduleIds
     * @return
     */
    int deleteTbGameScheduleAddendumByGameScheduleId(List<Integer> gameScheduleIds);

    /**
     * 插入赛程对战记录
     *
     * @param tbGameScheduleAddendum
     */
    void insertTbGameScheduleAddendum(TbGameScheduleAddendum tbGameScheduleAddendum);

    /**
     *  批量获取赛程对信息
     *
     * @param gameScheduleIds
     * @return
     */
    List<TbGameScheduleAddendum> selectTbGameScheduleAddendumByGameScheduleIds(List<Integer> gameScheduleIds);

    /**
     * 按照条件搜索赛事
     *
     * @param parmMap
     * @return
     */
    List<TbGameEvent> selectTbGameEventList(Map<String, Object> parmMap);

    /**
     * 查询用户赛事
     *
     * @param uid
     * @return
     */
    List<TbGameEventTeam> selectUidTbGameEventList(Integer uid, Integer pageNo, Integer pageSize);

    /**
     * 获取该栏目下的海报
     *
     * @param categoryId
     * @return
     */
    List<TbGamePoster> queryTbGamePosterList(Integer categoryId);

    /**
     * 根据轮次ID修改赛程信息
     * @param lastTeamListIndex
     * @param gameRoundId
     * @return
     */
    int updateTbGameScheduleByGameRoundId(String lastTeamListIndex,Integer gameRoundId);
}